package com.baomidou.ant.service.impl;

import com.baomidou.ant.entity.DeleteInfo;
import com.baomidou.ant.entity.ProcessInfo;
import com.baomidou.ant.entity.SysUser;
import com.baomidou.ant.entity.WorkOrder;
import com.baomidou.ant.mapper.DeleteInfoMapper;
import com.baomidou.ant.service.IDeleteInfoService;
import com.baomidou.ant.service.IProcessInfoService;
import com.baomidou.ant.service.ISysUserService;
import com.baomidou.ant.service.IWorkOrderService;
import com.baomidou.ant.vo.request.RequestDeleteReportInfoVo;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author jobob
 * @since 2022-03-18
 */
@Service
public class DeleteInfoServiceImpl extends ServiceImpl<DeleteInfoMapper, DeleteInfo> implements IDeleteInfoService {
    @Autowired
    private IProcessInfoService processInfoService;
    @Autowired
    private ISysUserService sysUserService;
    @Autowired
    private IWorkOrderService workOrderService;

    @Override
    public void addDeleteInfo(RequestDeleteReportInfoVo vo) {
        DeleteInfo deleteInfo=new DeleteInfo();
        deleteInfo.setDeleteProcessId(vo.getProcessId());
        ProcessInfo processInfo=processInfoService.getById(vo.getProcessId());
        deleteInfo.setDeleteProcessName(processInfo.getProcessName());
        SysUser sysUser=sysUserService.getById(vo.getUserId());
        deleteInfo.setDeleteWorkerName(sysUser.getUserName());
        deleteInfo.setDeleteWorkerNo(sysUser.getLoginName());
        WorkOrder workOrder=workOrderService.getById(vo.getOrderId());
        deleteInfo.setOrderNum(workOrder.getOrderNum());
        save(deleteInfo);
    }


}
